package com.baitai.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.baitai.common.utils.SecurityUtils;
import com.baitai.system.domain.vo.IncomeManagementStatementVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baitai.common.annotation.Log;
import com.baitai.common.core.controller.BaseController;
import com.baitai.common.core.domain.AjaxResult;
import com.baitai.common.enums.BusinessType;
import com.baitai.system.domain.IncomeManagementStatement;
import com.baitai.system.service.IIncomeManagementStatementService;
import com.baitai.common.utils.poi.ExcelUtil;
import com.baitai.common.core.page.TableDataInfo;

/**
 * 收益管理Controller
 * 
 * @author xx
 * @date 2024-08-26
 */
@RestController
@RequestMapping("/system/statement")
public class IncomeManagementStatementController extends BaseController
{
    @Autowired
    private IIncomeManagementStatementService incomeManagementStatementService;

    /**
     * 查询收益管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:statement:list')")
    @GetMapping("/list")
    public TableDataInfo list(IncomeManagementStatementVo incomeManagementStatement)
    {
        List<IncomeManagementStatement> list = incomeManagementStatementService.selectIncomeManagementStatementList(incomeManagementStatement);
        return getDataTable(list);
    }

    /**
     * 导出收益管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:statement:export')")
    @Log(title = "收益管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IncomeManagementStatementVo incomeManagementStatement)
    {
        List<IncomeManagementStatement> list = incomeManagementStatementService.selectIncomeManagementStatementList(incomeManagementStatement);
        ExcelUtil<IncomeManagementStatement> util = new ExcelUtil<IncomeManagementStatement>(IncomeManagementStatement.class);
        util.exportExcel(response, list, "收益管理数据");
    }

    /**
     * 获取收益管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:statement:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(incomeManagementStatementService.selectIncomeManagementStatementById(id));
    }

    /**
     * 新增收益管理
     */
    @PreAuthorize("@ss.hasPermi('system:statement:add')")
    @Log(title = "收益管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IncomeManagementStatement incomeManagementStatement)
    {
        return toAjax(incomeManagementStatementService.insertIncomeManagementStatement(incomeManagementStatement));
    }

    /**
     * 修改收益管理
     */
    @PreAuthorize("@ss.hasPermi('system:statement:edit')")
    @Log(title = "收益管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IncomeManagementStatement incomeManagementStatement)
    {
        return toAjax(incomeManagementStatementService.updateIncomeManagementStatement(incomeManagementStatement));
    }

    /**
     * 删除收益管理
     */
    @PreAuthorize("@ss.hasPermi('system:statement:remove')")
    @Log(title = "收益管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(incomeManagementStatementService.deleteIncomeManagementStatementByIds(ids));
    }
    /**
     * 删除收益管理
     */
    @Log(title = "收益管理", businessType = BusinessType.OTHER)
    @GetMapping(value = "/getUserList")
    public AjaxResult getUserList()
    {
        return AjaxResult.success(incomeManagementStatementService.getUserList(SecurityUtils.getUserId()));
    }
    /**
     * 删除收益管理
     */
    @Log(title = "收益管理", businessType = BusinessType.OTHER)
    @GetMapping(value = "/getPermission")
    public AjaxResult getPermission()
    {
        return AjaxResult.success("",incomeManagementStatementService.getPermission(SecurityUtils.getUserId()));
    }

    /**
     * 删除收益管理
     */
    @Log(title = "收益管理", businessType = BusinessType.OTHER)
    @GetMapping(value = "/setRatio")
    public AjaxResult setRatio(String ratio)
    {
        return AjaxResult.success("",incomeManagementStatementService.setRatio(SecurityUtils.getUserId(),ratio));
    }
    /**
     * 删除收益管理
     */
    @Log(title = "收益管理", businessType = BusinessType.OTHER)
    @GetMapping(value = "/getRatio")
    public AjaxResult getRatio()
    {
        return AjaxResult.success("",incomeManagementStatementService.getRatio(SecurityUtils.getUserId()));
    }

    /**
     * 删除收益管理
     */
    @Log(title = "收益管理", businessType = BusinessType.OTHER)
    @GetMapping(value = "/getRowRatio")
    public AjaxResult getRowRatio(Long id)
    {
        return AjaxResult.success("",incomeManagementStatementService.getRowRatio(id));
    }

    /**
     * 删除收益管理
     */
    @Log(title = "收益管理", businessType = BusinessType.OTHER)
    @PostMapping(value = "/setRowRatio")
    public AjaxResult setRowRatio(@RequestBody IncomeManagementStatement incomeManagementStatement)
    {
        return AjaxResult.success("",incomeManagementStatementService.setRowRatio(incomeManagementStatement));
    }

    /**
     * 删除收益管理
     */
    @GetMapping(value = "/getFullReport")
    public AjaxResult getFullReport()
    {
        incomeManagementStatementService.getFullReport();
        return AjaxResult.success();
    }
}
